package Menus;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;

import Announcements.Announcement;
import FrameWork.Menu;
import FrameWork.Utilities;
import Main.SpaceGame;

public class FullAnnouncementMenu extends Menu
{
	SpaceGame main;
	int height = SpaceGame.windowYSize-30;
	int pixXPos = 0;
	int pixYPos = 30;
	int width = SpaceGame.windowXSize;
	int level = 1;
	boolean cursorRequirement = false;
	
	public FullAnnouncementMenu(SpaceGame main)
	{
		this.main = main;
		if (main.announcementManager.announcementList.size()*16+15 > SpaceGame.windowYSize)
		{
			height = main.announcementManager.announcementList.size()*16;
			pixYPos = SpaceGame.windowYSize-height-Utilities.textInterval;
		}
		main.menuManager.setHasFullMenu(true);
	}
	
	@Override
	public void draw(Graphics g) 
	{
		g.translate(pixXPos, pixYPos);
		
		g.setColor(Color.LIGHT_GRAY);
		g.fillRect(0, -20, width, height-20);
		g.setColor(Color.DARK_GRAY);
		g.fillRect(5, 5, width-10, height+5);
		
		List<String> strings = new ArrayList<String>();
		List<Color>  colors= new ArrayList<Color>();
		
		for (Announcement a:main.announcementManager.announcementList)
		{
			colors.add(a.getColor());
			strings.add(a.getText());
		}
		
		printLines(g, strings, colors);
		
		g.translate(-pixXPos, -pixYPos);
	}

	@Override
	public boolean requiresCursor() 
	{
		return cursorRequirement;
	}

	@Override
	public void setRequiresCursor(boolean f) 
	{
		
	}

	@Override
	public int getLevel() 
	{
		return level;
	}
	
	public void scrollUp()
	{
		if (pixYPos < 16)
			pixYPos += Utilities.textInterval;
	}
	
	public void scrollDown()
	{
		if (pixYPos+height > SpaceGame.windowYSize-16)
			pixYPos -= Utilities.textInterval;
	}
}
